package br.ucb.musicbay.managedBean;

import java.rmi.RemoteException;

import net.webservicex.www.GeoIP;
import net.webservicex.www.GeoIPServiceSoapProxy;

public class LocationManagedBean {
	private String ip;
	private String pais;
	private String sigla;
			
	public String getPais() {
		setPais(getLocation().getCountryName());
		return pais;
	}

	public void setPais(String pais) {
		this.pais = pais;
	}

	public String getSigla() {
		setSigla(getLocation().getCountryCode());
		return sigla;
	}

	public void setSigla(String sigla) {
		this.sigla = sigla;
	}

	public String getIp() {
		setIp(getLocation().getIP());
		return ip;
	}

	public void setIp(String ip) {
		this.ip = ip;
	}

	public GeoIP getLocation() {
		try {
			GeoIP geo = new GeoIPServiceSoapProxy().getGeoIPContext();
			return geo;
		} catch (RemoteException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return null;
	}
}
